import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/constants/font_family.dart';
import 'package:flutter_eve_plugin/constants/font_weight.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/checkpoint/dungeon_rank.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';

class CheckpointPassRankItemWidget extends StatelessWidget {
  final int index;
  final DungeonRankInfo info;
  final bool vip;
  const CheckpointPassRankItemWidget({Key key, this.index, this.info, this.vip})
      : super(key: key);

  Color getColor(int index) {
    switch (index) {
      case 0:
        return Color(0x08EFA52B);
      case 1:
        return Color(0x08A3A1AB);
      case 2:
        return Color(0x08CC733F);
      default:
        return Colors.transparent;
    }
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      height: setRatio(78),
      child: Container(
        decoration: BoxDecoration(color: getColor(index)),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Row(
              children: <Widget>[
                Padding(
                  padding: EdgeInsets.only(left: setRatio(11)),
                  child: (index + 1) > 3
                      ? Container(
                          width: setRatio(40),
                          height: setRatio(37),
                          decoration: BoxDecoration(
                              image: DecorationImage(
                            image: AssetImage(
                                imageUtilYeXiu('checkpoint/icon_rank_non@3x')),
                          )),
                          child: Container(
                            child: Column(
                              children: <Widget>[
                                SizedBox(
                                  height: setRatio(13),
                                ),
                                Text(
                                  '${index + 1}',
                                  style: TextStyle(
                                      decoration: TextDecoration.none,
                                      color: Color(0xFFFFFFFF),
                                      fontFamily: FontFamily.PMZD,
                                      fontSize: setTextSp(15)),
                                )
                              ],
                            ),
                          ),
                        )
                      : Image.asset(
                          imageUtilYeXiu(
                              'checkpoint/icon_rank_no${index + 1}@3x'),
                          width: setRatio(40),
                          height: setRatio(37),
                          fit: BoxFit.cover,
                        ),
                ),
                Padding(
                  padding: EdgeInsets.only(left: setRatio(19)),
                  child: Stack(overflow: Overflow.visible, children: <Widget>[
                    Container(
                      width: setRatio(45),
                      height: setRatio(45),
                      decoration: BoxDecoration(
                          image: DecorationImage(
                              image: NetworkImage(info?.pic ?? '')),
                          border: Border.all(
                              color: Color(0xFFB7BBCE), width: setRatio(1)),
                          borderRadius: BorderRadius.circular(setRatio(23.5))),
                    ),
                    Positioned(
                      right: setRatio(-8),
                      top: setRatio(-10),
                      child: vip
                          ? Image.asset(
                              imageUtilYeXiu(
                                  'checkpoint/icon_checkpoint_vip@3x'),
                              width: setRatio(35),
                              height: setRatio(25),
                            )
                          : Container(),
                    )
                  ]),
                ),
                Padding(
                  padding: EdgeInsets.only(left: setRatio(11)),
                  child: Text(
                    info?.nick ?? '',
                    style: TextStyle(
                        decoration: TextDecoration.none,
                        color: Color(0x8FFFFFFF),
                        fontFamily: FontFamily.PINGFANG,
                        fontWeight: FontWeightCustom.PF_Medium,
                        fontSize: setTextSp(13)),
                  ),
                ),
              ],
            ),
            Row(
              children: <Widget>[
                Text(
                  'LV.${info?.level ?? 0}',
                  style: TextStyle(
                      decoration: TextDecoration.none,
                      color: Color(0xcFFFFFFF),
                      fontFamily: FontFamily.PMZD,
                      fontSize: setTextSp(12)),
                ),
                SizedBox(
                  width: setRatio(50),
                ),
                Text(
                  '${info?.score ?? 0}',
                  style: TextStyle(
                      decoration: TextDecoration.none,
                      color: Color(0xfFFFFFFF),
                      fontFamily: FontFamily.PMZD,
                      fontSize: setTextSp(18)),
                ),
                SizedBox(
                  width: setRatio(24),
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}
